package com.lovo.controller;


import com.lovo.bean.Detail;
import com.lovo.service.IDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * ????????ϸ? 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@RestController
@RequestMapping("hd/detail")
public class DetailController {
    @Autowired
    IDetailService detailService;

    @GetMapping("findDetailByProductId/{productId}")
    public List<Detail> findDetailByProductId(@PathVariable("productId") Integer productId) {

        return detailService.findDetailByProductId(productId);
    };

    @PutMapping("sellProduct/{productId}/{num}")
    public boolean sellProduct(@PathVariable("productId") Integer productId,
                               @PathVariable("num") Integer num) {
        return detailService.sellProduct(productId, num);
    };


}
